import { BaseEntity, Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { LogAppender, LogLevel } from '../constants/log.constant';

@Entity('logs')
export class LogEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('enum', { enum: LogAppender, comment: '日志类别' })
  appender: LogAppender;

  @Column('enum', { enum: LogLevel, comment: '日志级别' })
  level: LogLevel;

  @Column('varchar', { comment: '日志内容' })
  message: string;

  @Column('varchar', { comment: '日志详情', nullable: true })
  detail: string;

  @CreateDateColumn({ name: 'created_at', comment: '创建时间(typeorm自动生成)' })
  @Index()
  createdAt: Date;
}
